/**
 * @file request.h
 * @author your name (you@domain.com)
 * @brief
 * @version 0.1
 * @date 2024-07-19
 *
 * @copyright Copyright (c) 2024
 *
 */

#pragma once

#include <cstdint>
#include <string>
#include <vector>
#include <unordered_map>

#include "defs.h"

namespace wheels {

class Request {
   public:
    Request(int session, std::string &client) : 
        m_clientAddr(client), m_session(session) {}

    ~Request() = default;

    HttpMethod GetMethod(void) const { return m_method; }

    const std::string &GetPath(void) const { return m_path; }

    std::string GetHeader(const std::string &key) const;

    long GetBodySize() const { return m_bodySize; }

    const std::string & GetBodyType() const { return m_bodyType; }

    std::string GetBody() const;

    /// @brief 获取body数据到文件中
    /// @param filePath
    /// @return
    int GetBody(const char *filePath);

   public:
    HttpMethod m_method;
    std::string m_path;
    std::string m_bodyType;
    std::string m_clientAddr;
    std::unordered_map<std::string, std::string> m_headers;
    long m_bodySize = 0;

   private:
    int m_session = -1;
    std::vector<uint8_t> m_body;
};

}  // namespace wheels
